<?php include '../public/header.php' ?>
<?php include '../public/header_index.php' ?>
<style>
    .layui-table-header tr:nth-child(1) th:nth-child(14)
    {
        background-color: #E1F6C0;
    }
    .layui-table-header tr:nth-child(1) th:nth-child(15)
    {
        background-color: #FDF0E4;
    }
</style>
<body class="laytp-container">
<div id="opt_nav">
</div>

<div class="layui-card" id="search-form">
    <div class="layui-card-body">
        <form class="layui-form" id="TableSearchFormId" lay-filter="TableSearchForm" onkeydown="keyTableSearch('TableSearchForm', 'datalist')">
            <div class="layui-form-item">
                <div class="layui-row">
                    <div class="layui-col-md3">
                        <label class="layui-form-label">工程名称</label>
                        <div class="layui-input-block">
                            <input type="text" name="name" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <label class="layui-form-label">工程编号</label>
                        <div class="layui-input-block">
                            <input type="text" name="number" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <label class="layui-form-label">甲方名称</label>
                        <div class="layui-input-block">
                            <input type="text" name="jiaer" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">工程负责人</label>
                        <div class="layui-input-block">
                            <input type="text" name="gofuer" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">所在地</label>
                        <div class="layui-input-block">
                            <input type="text" name="areas" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">投标单位</label>
                        <div class="layui-input-block">
                            <input type="text" name="tou_unit" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">报备方式</label>
                        <div class="layui-input-block">
                            <div id="lanshi" class="xmselect_div">
                                <div class="xmselect_title">请选择</div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">资金来源</label>
                        <div class="layui-input-block">
                            <div id="zilai" class="xmselect_div">
                                <div class="xmselect_title">请选择</div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">开标时间</label>
                        <div class="layui-input-block">
                            <input type="text" readonly name="kaidt" placeholder="请输入" autocomplete="off" class="layui-input bdate_sea_range_ymdhi">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">开标类型</label>
                        <div class="layui-input-block">
                            <div id="kaitype" class="xmselect_div">
                                <div class="xmselect_title">请选择</div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">工程发布平台</label>
                        <div class="layui-input-block">
                            <div id="kailei" class="xmselect_div">
                                <div class="xmselect_title">请选择</div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">招标方式</label>
                        <div class="layui-input-block">
                            <div id="zhaotype" class="xmselect_div">
                                <div class="xmselect_title">请选择</div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">招标代理公司</label>
                        <div class="layui-input-block">
                            <input type="text" name="zhao_unit" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">报名截止时间</label>
                        <div class="layui-input-block">
                            <input type="text" readonly name="enddt_bao" placeholder="请输入" autocomplete="off" class="layui-input bdate_sea_range_ymdhi">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">投标截止时间</label>
                        <div class="layui-input-block">
                            <input type="text" readonly name="enddt_tou" placeholder="请输入" autocomplete="off" class="layui-input bdate_sea_range_ymdhi">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">经营备案人</label>
                        <div class="layui-input-block">
                            <input type="text" name="jinger_name" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">投标负责人</label>
                        <div class="layui-input-block">
                            <input type="text" name="touer_name" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">投标状态：</label>
                        <div class="layui-input-block">
                            <select id="state" name="state" lay-filter="state">
                                <option value="">请选择</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">业务归属</label>
                        <div class="layui-input-block">
                            <div id="gui_unit" class="xmselect_div">
                                <div class="xmselect_title">请选择</div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <div class="layui-form-item search-div">
                            <div class="layui-form-item layui-inline">
                                <button class="laytp-btn laytp-btn-md laytp-btn-primary" id="TableSearchButton" type="button"><i class="layui-icon layui-icon-search"></i>查询</button>
                                <button class="layui-btn layui-btn-primary" onclick="listTableReset()" id="TableSearchReset" type="reset" ><i class="layui-icon layui-icon-refresh"></i>重置</button>
                                <div id="search_open" onclick="toggle_search()">
                                    <i class="layui-icon layui-icon-down"></i>展开
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>

<div class="layui-card" id="table-card">
    <div class="layui-card-body">
        <div class="layui-row">
            <div class="layui-col-md12" id="table_list">
                <div class="layui-card-body">
                    <table id="datalist" lay-filter="datalist"></table>
                </div>
            </div>
        </div>
    </div>
</div>

<script type="text/html" id="test-dropdown-toolbar-barDemo">
    <div class="tab-list-authbut">
        <a href="javascript:;" class="bar_opt" onclick="auth_but_func_show('查看','{{d.LAY_TABLE_INDEX}}')">查看</a>
    </div>
</script>
<script type="text/html" id="toolbarDemo">
    <div class = "layui-btn-container">
    </div>
</script>
<script>


    var param_bidid = getQueryVariable('bidid') || 0;

    var colsArr = [];
    var zhiFieldNum;
    layui.use(["laytp",'laypage','table','dropdown','form','soulTable'], function () {
        var laypage = layui.laypage, table = layui.table, dropdown = layui.dropdown, form = layui.form, soulTable = layui.soulTable;
        $('#TableSearchReset').click(function () {
            $('.xmselect_div>xm-select').find('.xm-label-block').css('display','none');
            $('.xmselect_div').append('<div class="xmselect_title">请选择</div>');
            searchTableFunc(form, table)
        });
        setSouTableExport('前期费一览-办事处');

        facade.ajax({url: ask_qian_ban_lan_list, data:{seatype:'col'}}).done(function(res){
            if (res.code === 2000) {




                colsArr.push({field: 'daifu_kou_fee', title: '代理公司收取代理服务费(元)'});
                var ke_zhi_list = res.data.ke_zhi_list;
                zhiFieldNum = ke_zhi_list.length+2;
                for (var mmm in ke_zhi_list) {
                    colsArr.push({field: 'zhi_'+ke_zhi_list[mmm].value, title: ke_zhi_list[mmm].title});
                }
                colsArr.push({field: 'zhi_he', title: '小计'});


                var mytable = table.render({
                    elem: "#datalist",id: "datalist"
                    ,url: facade.url(ask_qian_ban_lan_list),where: {bidid:param_bidid}, page: true, height: 'full-140'
                    ,soulSort: TabInit.soulSort,method: TabInit.method, toolbar: TabInit.toolbar, overflow: TabInit.overflow
                    ,defaultToolbar: TabInit.defaultToolbar,filter: TabInit.filter
                    ,request: TabInit.request,response: TabInit.response,contextmenu:get_table_contextmenu(soulTable)
                    ,text: TabInit.text,totalRow: true
                    ,parseData: function (res) {

                        var state_str = '<option value="">请选择</option>';
                        var state = res.data.state;
                        for (var key in state){
                            if(res.data.is_state == key){
                                state_str += '<option value="'+key+'" selected>'+state[key]+'</option>';
                            }else {
                                state_str += '<option value="'+key+'">'+state[key]+'</option>';
                            }

                        }
                        $("#state").html(state_str);

                        xmselect_dan('chanid', res.data.chanid, res.data.is_chanid, function (res) {
                            setTimeout(function () {
                                searchTableFunc(form, table);
                            },100)
                        })

                        xmselect_dan('tou_unit', res.data.tou_unit, res.data.is_tou_unit, function (res) {
                            setTimeout(function () {
                                searchTableFunc(form, table);
                            },100)
                        })

                        xmselect_dan('gui_unit', res.data.gui_unit, res.data.is_gui_unit, function (res) {
                            setTimeout(function () {
                                searchTableFunc(form, table);
                            },100)
                        })

                        xmselect_dan('bidtype', res.data.bidtype, res.data.is_bidtype, function (res) {
                            setTimeout(function () {
                                searchTableFunc(form, table);
                            },100)
                        })

                        xmselect_dan('lanshi', res.data.lanshi, res.data.is_lanshi, function (res) {
                            setTimeout(function () {
                                searchTableFunc(form, table);
                            },100)
                        })

                        xmselect_dan('zilai', res.data.zilai, res.data.is_zilai, function (res) {
                            setTimeout(function () {
                                searchTableFunc(form, table);
                            },100)
                        })

                        xmselect_dan('kaitype', res.data.kaitype, res.data.is_kaitype, function (res) {
                            setTimeout(function () {
                                searchTableFunc(form, table);
                            },100)
                        })

                        xmselect_dan('kailei', res.data.kailei, res.data.is_kailei, function (res) {
                            setTimeout(function () {
                                searchTableFunc(form, table);
                            },100)
                        })

                        xmselect_dan('zhaotype', res.data.zhaotype, res.data.is_zhaotype, function (res) {
                            setTimeout(function () {
                                searchTableFunc(form, table);
                            },100)
                        })


                        render_from();
                        return {
                            "code": res.code,
                            "msg": res.message,
                            "count": res.data.data.total,
                            "data": res.data.data.data
                        };
                    }
                    , cols: [[
                        {type: "checkbox", fixed: 'left',rowspan:2}
                        ,{type:'numbers',title:'序号',totalRowText: '合计',fixed:'left',rowspan:2}
                        ,{field: 'gui_unit_name', title: '业务归属',rowspan:2}
                        ,{field: 'gofuer', title: '工程负责人',rowspan:2}
                        ,{field:'name',title:'工程名称',fixed:'left',rowspan:2,templet: function(d){
                                return '<span class="colorlan" onclick="openPage(\'../bid/show.php?id='+d.id+'\')">'+d.name+'</span>';
                            }}
                        ,{field: 'number', title: '工程编号',rowspan:2}
                        ,{field: 'state_name', title: '投标状态',rowspan:2}


                        ,{field:'kongfee',title:'工程控制价(元)',rowspan:2,totalRow: true,templet: function(d){
                                return parseFormatNum(d.kongfee);
                            }}
                        ,{field: 'lanshi_name', title: '报备方式',rowspan:2}
                        ,{field: 'kaidt', title: '开标时间',rowspan:2}
                        ,{field:'qian_zhi_fee',title:'支出(元)',rowspan:2,totalRow: true,templet: function(d){
                                if(d.qian_zhi_fee){
                                    return '<span class="colorlan" onclick="openNavPage(\'前期费支付\',\'qian_zhi/index.php?status=1&bidid='+d.id+'\');">'+parseFormatNum(d.qian_zhi_fee)+'</span>';
                                }else{
                                    return '';
                                }
                            }}
                        ,{field:'ying_dian_fee',title:'应收垫付利息(元)',hide:true,rowspan:2,totalRow: true,templet: function(d){
                                if(d.ying_dian_fee){
                                    return '<span class="colorlan" onclick="openNavPage(\'投标保证金缴纳\',\'tou_jiao/index.php?status=1&ziqu=2&bidid='+d.id+'\');">'+parseFormatNum(d.ying_dian_fee)+'</span>';
                                }else{
                                    return '';
                                }
                            }}
                        ,{field: '', title: '支出明细',align:'center',colspan:zhiFieldNum}
                        ,{field:'tou_jiao',title:'投标保证金缴纳(元)',rowspan:2,totalRow: true,templet: function(d){
                                if(d.tou_jiao){
                                    return '<span class="colorlan" onclick="openNavPage(\'投标保证金缴纳\',\'tou_jiao/index.php?status=1&bidid='+d.id+'\');">'+parseFormatNum(d.tou_jiao)+'</span>';
                                }else{
                                    return '';
                                }
                            }}

                        ,{field:'tou_fan',title:'投标保证金返还(元)',rowspan:2,totalRow: true,templet: function(d){
                                if(d.tou_fan){
                                    return '<span class="colorlan" onclick="openNavPage(\'投标保证金返还\',\'tou_fan/index.php?status=1&bidid='+d.id+'\');">'+parseFormatNum(d.tou_fan)+'（'+parseFormatNum(d.tou_fan_11)+' + '+parseFormatNum(d.tou_fan_22)+'）</span>';
                                }else{
                                    return '';
                                }
                            }}
                    ],
                        colsArr
                    ]
                    , done: function (res) {
                        soulTable.render(this);
                    }
                });

            }
        });




        listTableSearch(form, table);
    });



</script>
</body>
</html>
